package resources.teacher;

import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import model.teacher.Teacher;
import dao.Linker;
import dao.TeacherDAO;

public class ScheduleRes 
{
	@Context
	UriInfo uriInfo;
	
	@Context
	Request request;
	
	String teacherId;
	
	public ScheduleRes(UriInfo uriInfo, Request request, String teacherId) 
	{
		this.uriInfo = uriInfo;
		this.request = request;
		this.teacherId = teacherId;
	}
	
	@GET
	@Produces(MediaType.TEXT_XML)
	public Teacher getDataBrowser() 
	{
		Linker.sort();
		
		Teacher teacher = TeacherDAO.getTeachersScheduleCP().get(teacherId);
		
		if(teacher == null)
			throw new RuntimeException("Get: Teacher Schedule with " + teacherId +  " not found");
		return teacher;
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public Teacher getDataBrowserJSON() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XHTML_XML)
	public Teacher getDataBrowserXHTML() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XML)
	public Teacher getDataBrowserXML() 
	{
		return getDataBrowser(); 
	}
}